<%-- 
    Document   : capnhatdealcontent
    Created on : Oct 12, 2011, 10:22:53 AM
    Author     : Administrator
--%>

<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DecimalFormat"%>
<%@page import="java.util.List"%>
<%@page import="hibernate.pojo.Loaisanpham"%>
<%@page import="hibernate.pojo.Sanpham"%>
<%@page import="org.hibernate.HibernateException"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!--
<link type="text/css" rel="stylesheet" href="Admin/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.css?random=20051112" media="screen"></link>
<script type="text/javascript" src="Admin/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.js?random=20060118"></script>
-->
<link type="text/css" rel="stylesheet" href="Admin/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.css" />
<script type="text/javascript" src="Admin/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.js"></script>
<!--
<script type="text/javascript" src="Admin/jquery-calendar/jquery.js"></script>
<script type="text/javascript" src="Admin/jquery-calendar/jquery-calendar.js"></script>
<script type="text/javascript">
        $(document).ready(function () {
                $('.calendarFocus').calendar();
        });
</script>
<link rel="stylesheet" href="Admin/jquery-calendar/jquery-calendar.css" />
-->

<%
    try 
    {
        //DecimalFormat df = new DecimalFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        Sanpham sanpham = (Sanpham) request.getAttribute("DealCapNhat");
        if (sanpham != null) {
%>
<form action="admindealprocesscontroller?action=update&masanpham=<%=sanpham.getMaSanPham()%>" method="post" name="form1234" id="form1234"> 

    <table width="80%" align="center" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td colspan="3">CẬP NHẬT SẢN PHẨM</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>Mã Sản Phẩm</td>
            <td><label>
                    <input type="text" readonly="readonly" name="txtMaSanPham" id="txtMaSanPham" value="<%=sanpham.getMaSanPham()%>" />
                </label></td>
            <td>Loại Sản Phẩm</td>
            <td><label>
                    <select name="cboLoaiSanPham" id="cboLoaiSanPham">
                        <option value="<%=sanpham.getLoaisanpham().getMaLoaiSanPham()%>"><%=sanpham.getLoaisanpham().getTenLoaiSanPham()%></option>
                        <%
                            List<Loaisanpham> arrLoaisanpham = (List<Loaisanpham>) request.getAttribute("DanhSachLoaiSanPham");
                            for (int i = 0; i < arrLoaisanpham.size(); i++) {
                                Loaisanpham category = arrLoaisanpham.get(i);
                        %>
                        <option value="<%=i + 1%>"> <%=category.getTenLoaiSanPham()%> </option>
                        <%
                            }
                        %>
                    </select>
                </label></td>
        </tr>
        <tr>
            <td>Tên Sản Phẩm</td>
            <td><label>
                    <input type="text" name="txtTenSanPham" id="txtTenSanPham" value="<%=sanpham.getTenSanPham()%>"/>
                </label></td>
            <td>Tên Tiêu Đề Sản Phẩm</td>
            <td><label>
                    <input type="text" name="txtTieuDeSanPham" id="txtTieuDeSanPham" value="<%=sanpham.getTieuDeSanPham()%>" />
                </label></td>
        </tr>
        <tr>
            <td>Giá Bán</td>
            <td><label>
                    <input type="text" name="txtGiaBan" id="txtGiaBan" value="<%=sanpham.getGiaBan()%>" />
                </label></td>
            <td>Trị Giá</td>
            <td><label>
                    <input type="text" name="txtTriGia" id="txtTriGia" value="<%=sanpham.getTriGia()%>" />
                </label></td>
        </tr>
        <tr>
            <td>Tiết Kiệm</td>
            <td><label>
                    <input type="text" name="txtTietKiem" id="txtTietKiem" value="<%=sanpham.getTietKiem()%>" />
                </label></td>
        </tr>
        <tr>
            <td>Ngày Bắt Đầu Khuyến Ngày</td>
            <td>
                <table>			
                    <tr>
                        <td>
                            <input type="text" value="<%=df.format(sanpham.getNgayBatDauKhuyenMai())%>"  name="txtNgayBatDauKhuyenMai" id="txtNgayBatDauKhuyenMai"/>
                            <input type="button" value="Calendar" onclick="displayCalendar(document.forms[0].txtNgayBatDauKhuyenMai,'yyyy-mm-dd hh:ii:00',this,true)"/>
                            <!-- <input type="text" class="calendarFocus" value=""/> -->
                        </td>
                    </tr>
                </table>	</td>
            <td>Ngày Kết Thúc Khuyến Mãi</td>
            <td>
                <table>			
                    <tr>
                        <td>
                            <input type="text" value="<%=df.format(sanpham.getNgayHetHanKhuyenMai())%>"  name="txtNgayKetThucKhuyenMai" id="txtNgayKetThucKhuyenMai"/>
                            <input type="button" value="Calendar" onclick="displayCalendar(document.forms[0].txtNgayKetThucKhuyenMai,'yyyy-mm-dd hh:ii:00',this,true)"/>
                        </td>
                    </tr>
                </table>      
            </td>
        </tr>
        <tr>
            <td>Thời Gian Khuyến Mãi</td>
            <td><label>
                    <input type="text" name="txtThoiGianKhuyenMai" id="txtThoiGianKhuyenMai" value="<%=sanpham.getThoiGianKhuyenMai()%>" />
                </label></td>
            <td>Lượt Mua</td>
            <td><label>
                    <input type="text" name="txtLuotMua" id="textfield7" value="<%=sanpham.getLuotMua()%>" />
                </label></td>
        </tr>
        <tr>
            <td>Tình Trạng Khuyến Mãi</td>
            <td><label>
                    <input type="text" name="txtTinhTrangKhuyenMai" id="txtTinhTrangKhuyenMai" value="<%=sanpham.getTinhTrangKhuyenMai()%>"/>
                </label></td>
            <td>Tình Trạng Xóa</td>
            <td><label>
                    <input type="text" name="txtTinhTrangXoa" id="txtTinhTrangXoa" value="<%=sanpham.getTinhTrangXoa()%>" />
                </label></td>
        </tr>
        <tr>
            <td style="vertical-align: text-top">Ảnh Sản Phẩm</td>
            <td style="vertical-align: text-top">
                <!--<input type="file" name="fileUploadAnh" id="fileUploadAnh" /><br/> -->
                <input type="text" name="fileUploadAnh" value="<%=sanpham.getAnhDaiDien()%>" />
                <input type="button" name="button" id="button" value="Chọn Ảnh" onClick="window.open('adminuploadfilecontroller?action=viewupload','mywindow','width=500,height=220')" />
                <img src="<%=sanpham.getAnhDaiDien()%>" width="150" height="150" />
            </td>
            <td style="vertical-align: text-top"">Ghi Chú</td>
            <td style="vertical-align: text-top"><label>
                    <textarea name="txtGhiChu" id="txtaGhiChu" cols="45" rows="5"><%=sanpham.getGhiChu()%></textarea>
                </label>
            </td>
        </tr>
        <tr>
            <td colspan="4"><label>
                    <input type="submit" name="Submit" id="button" value="Cập Nhật" />
                    <input type="reset" name="button2" id="button2" value="Nhập Lại" />
                </label></td>
        </tr>
    </table>
</form>
<%
        } else {
            out.println("Không lấy được sản phẩm.");
        }
    } catch (HibernateException ex) {
        out.println(ex);
    }
%>